<template>
	<view class="file-edit">
		<view class="file-item" v-for="file in fileList" :key="file.id">
			<view class="file-type">
				JPG
			</view>
			<view class="file-desc">
				<view class="flex-left">
					<view class="file-name">
						a.jpg
					</view>
					<view>
						<span>大小</span>.
						<span class="filetype-deac">类型简述</span>
					</view>


				</view>
				<uni-icons fontFamily="iconfont" :size="20" color="#626262">{{'\ue60a'}}</uni-icons>
			</view>
		</view>
		<view class="add-file file-item">
			<uni-icons fontFamily="iconfont" :size="20" color="#626262">{{'\ue60a'}}</uni-icons>
			<view class="add-btn" @click="openPopup">
				添加文件
			</view>
		</view>
		<!-- <uni-file-picker v-model="imageValue" fileMediatype="image" mode="grid" ><text>选择图片</text></uni-file-picker> -->
		<uni-popup ref="popup" background-color="#fff" type="bottom">
			<view class="popup-content">
				<view class="upload-desc"> 上传自</view>
				<view class="upload-from">
					<uni-icons fontFamily="iconfont" :size="20" color="#626262">{{'\ue60a'}}</uni-icons>
					<uni-file-picker v-model="imageValue" file-mediatype="all" :sourceType="['album']">
						<text>设备文件</text>
					</uni-file-picker>
				</view>
				<view class="upload-from">

					<uni-icons fontFamily="iconfont" :size="20" color="#626262">{{'\ue60a'}}</uni-icons>
					<uni-file-picker v-model="imageValue" file-mediatype="all" :sourceType="['camera']">
						<text>照相机</text>
					</uni-file-picker>
				</view>

			</view>
		</uni-popup>
		
	</view>
</template>

<script>
	export default {
		props: {
			fileList: {
				type: Array,
				default: () => [{},
					{}
				]
			}
		},
		data() {
			return {
				listStyles: {
					// 是否显示边框
					border: true,
					// 是否显示分隔线
					dividline: true,
					// 线条样式
					borderStyle: {
						width: 1,
						color: 'blue',
						style: 'dashed',
						radius: 2
					}
				},
				imageValue: [],
				fileLists: [],
			}
		},
		methods: {
			openPopup() {
				console.log(11111)
				// uni.chooseMessageFile({
				// 	count: 1, // 默认选择一个文件
				// 	type: 'all', // 可以选择所有类型文件
				// 	success: (res) => {
				// 		console.log(res.tempFiles[0].path); // 文件的本地路径
				// 		// 可以进一步处理文件，如上传等
				// 	},
				// 	fail: (err) => {
				// 		console.error(err);
				// 	}
				// });
				// this.$refs.popup.open("bottom")

			},
			upload() {

			}

		},

	}
</script>


<style lang="scss" scoped>
	@import "@/static/iconfont/iconfont.css";

	.file-edit {
		.file-item {
			display: flex;
			align-items: center;
			background-color: #fafafa;
			padding-left: 10px;
			// padding-right: 18px;

			.file-type {
				width: 32px;
				height: 32px;
				line-height: 32px;
				text-align: center;
				background-color: blue;
				color: #fff;
				font-size: 12px;
				border-radius: 2px;
				margin-left: -4px
			}

			.file-desc {
				margin-left: 8px;
				flex: 1;
				display: flex;
				align-items: center;
				padding: 8px 0;
				padding-right: 18px;
				border-bottom: 1px solid #eee;

				.flex-left {
					flex: 1;
					display: flex;
					flex-direction: column;
				}
			}
		}

		.add-file {
			.add-btn {
				margin-left: 18px;
				padding: 12px 0;
			}
		}

		.popup-content {
			padding: 32px 12px 12px 12px;
			background-color: #fff;
			border-radius: 4px 4px 0 0;

			.upload-from {
				padding: 12px 0;
				display: flex;

				text {
					margin-left: 24px;
				}
			}

			.upload-desc {
				margin-bottom: 12px;
			}
		}
	}
</style>